<?
/**
**Date 2015-07-02 10:47
**燕塞湖对接 
**User by PZP
**/
class YanSaiHu{
	public function __construct($UUlid){
		switch ($UUlid){
			case 9999:
				$this->pstrUserId = "000000";
				$this->pstrPsw = "123456";
			break;			
			case 9415:  //百合燕塞湖
				$this->pstrUserId = "百合国旅";
				$this->pstrPsw = "921118";
			break;
			case 8533:  //畅游燕塞湖
				$this->pstrUserId = "畅游旅游服务公司";
				$this->pstrPsw = "5866658666";
			break;
			default:
			break;
		}
		$this->client = new SoapClient('http://www.0335u.cn/webservice/order.asmx?wsdl');
	}
	
	
	//提交订单
	public function oSaveRCode($request_array){
		$request = $this->client->oSaveRCode(array("pstrUserId"=>$this->pstrUserId,"pstrPsw"=>$this->pstrPsw,"pstrPhone"=>$request_array['UUordertel'],"piCount"=>$request_array['UUtnum']));	
		if(strlen($request->oSaveRCodeResult)>=6)
			return $request->oSaveRCodeResult;
		else{
			$this->logfile(date('Y-m-d H:i:s')."--".$request_array['UUordertel']."->".$request->oSaveRCodeResult);
			return 101;
		}
	}
	
	//取消订单
	public function oCancelOrder($request_array){
		$request = $this->client->oCancelOrder(array("pstrUserId"=>$this->pstrUserId,"pstrPsw"=>$this->pstrPsw,"pstrCode"=>$request_array['APIOrdern'],"pstrPhone"=>$request_array['ordertel']));		
		if($request->oCancelOrderResult ==  2)
			return 100;
		else{
			$this->logfile(date('Y-m-d H:i:s')."--".$request_array['UUordertel']."->".$request->oCancelOrderResult);
			return 101;
		}
		
	}	
	
	//查询订单
	public function oQuary(){
		$request = $this->client->oQuary($this->pstrUserId,$this->pstrPsw,$request_array['pstrCode'],$request_array['pstrPhone']);		
		print_r($request);
		
	}
	
	
		//错误日志
	public function logfile($txt){
		$fp = fopen('/var/www/html/new/d/module/api/YanSaiHu/ysh_errorlog.txt',"a");
		flock($fp, LOCK_EX) ;
		fwrite($fp,$txt."\n");
		flock($fp, LOCK_UN);
		fclose($fp); 
	}
}
// $UUlid = 123;
// $ysh = new YanSaiHu($UUlid);
// $request_array = array(
	// "UUordertel"=>"13346256746",
	// "UUtnum"=>2,
// );
// $request_array = array(
	// "UUordertel"=>"13346256746",
	// "pstrCode"=>"344034",
// );
// $oSaveRCode = $ysh->oSaveRCode($request_array);print_r($oSaveRCode);
// $oCancelOrder = $ysh->oCancelOrder($request_array);print_r($oCancelOrder);
?>